package com.yanqu.road.entity.activity.sonhai.data;

import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.activity.sonhai.enums.SonHaiWinFlagEnum;
import org.apache.mina.util.ConcurrentHashSet;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 兽王数据
 */
public class SonHaiBeastBossData {

    //BOSS事件配置ID
    private int eventId;

    //区域ID
    private int regionId;

    //异兽数据
    private SonHaiBeastData beastData;

    //是否镇伏，0：未镇伏，1：已镇伏
    private int winFlag;

    //领取过兽王奖励的玩家
    private Set<Long> rewardUserIdSet = new ConcurrentHashSet<>();

    //boss的地块（4块）
    private List<SonHaiXYData> positionList = new ArrayList<>();

    //玩家攻击次数
    private Map<Long, Integer> attNumMap = new ConcurrentHashMap<>();

    public SonHaiBeastBossData() {}

    public SonHaiBeastBossData(int eventId, int regionId, SonHaiBeastData beastData, List<SonHaiXYData> positionList) {
        this.eventId = eventId;
        this.regionId = regionId;
        this.beastData = beastData;
        this.winFlag = SonHaiWinFlagEnum.WIN_NOT.getType();
        this.positionList = positionList;
    }

    public int getEventId() {
        return eventId;
    }

    public void setEventId(int eventId) {
        this.eventId = eventId;
    }

    public int getRegionId() {
        return regionId;
    }

    public void setRegionId(int regionId) {
        this.regionId = regionId;
    }

    public SonHaiBeastData getBeastData() {
        return beastData;
    }

    public void setBeastData(SonHaiBeastData beastData) {
        this.beastData = beastData;
    }

    public int getWinFlag() {
        return winFlag;
    }

    public void setWinFlag(int winFlag) {
        this.winFlag = winFlag;
    }

    public Set<Long> getRewardUserIdSet() {
        return rewardUserIdSet;
    }

    public void addRewardUserIdSet(Long userId) {
        this.rewardUserIdSet.add(userId);
    }

    public void setRewardUserIdSet(Set<Long> rewardUserIdSet) {
        this.rewardUserIdSet = rewardUserIdSet;
    }

    public List<SonHaiXYData> getPositionList() {
        return positionList;
    }

    public void setPositionList(List<SonHaiXYData> positionList) {
        this.positionList = positionList;
    }

    public Map<Long, Integer> getAttNumMap() {
        return attNumMap;
    }

    public int getAttNum(long userId) {
        return attNumMap.getOrDefault(userId, 0);
    }

    public void addAttNum(long userId) {
        if (attNumMap.containsKey(userId)) {
            attNumMap.put(userId, attNumMap.get(userId) + 1);
        } else {
            attNumMap.put(userId, 1);
        }
    }

    public void setAttNumMap(Map<Long, Integer> attNumMap) {
        this.attNumMap = attNumMap;
    }

    /**
     * 判断是否领取过兽王奖励
     * @param userId
     * @return
     */
    public boolean checkReceiveReward(long userId) {
        return rewardUserIdSet.contains(userId);
    }
}
